package com.sg.service.biz.component.nb;

import cn.hutool.core.bean.BeanUtil;
import com.sg.dto.biz.component.req.ImplementSmartSessionReceiveFieldInputReqDto;
import com.sg.dto.biz.component.req.ObtainQuantitativeScoreForAchievementLevelCalcReqDto;
import com.sg.dto.biz.component.res.ImplementSmartSessionReceiveFieldInputRespDto;
import com.sg.dto.biz.component.res.ObtainQuantitativeScoreForAchievementLevelCalcRespDto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ： 手工接入方法
 * @version 1.0
 * @since 2022/5/28 15:32
 */
@Service
public class NbTargetCalc {
    /**
     * code:receptionService
     * name:M2接收入参字段
     * desc:undefined
     * gen by moon at 3/24/2024, 4:32:51 AM
     **/
    @Trace(operationName = "M2接收入参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementSmartSessionReceiveFieldInputRespDto implementSmartSessionReceiveFieldInput(ImplementSmartSessionReceiveFieldInputReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementSmartSessionReceiveFieldInputRespDto.class);
    }

    /**
     * code:quantitativeScoreForAchievementLevelCalc
     * name:M2获取成果等级转量化得分
     * desc:undefined
     * gen by moon at 4/25/2024, 1:48:46 PM
     **/
    @Trace(operationName = "M2获取成果等级转量化得分")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ObtainQuantitativeScoreForAchievementLevelCalcRespDto obtainQuantitativeScoreForAchievementLevelCalc(ObtainQuantitativeScoreForAchievementLevelCalcReqDto reqDto) {
        ObtainQuantitativeScoreForAchievementLevelCalcRespDto retData = new ObtainQuantitativeScoreForAchievementLevelCalcRespDto();
        Map<String, Double> infoIndex = new HashMap<>();
        for (DataSetsListOneDto dataOne : reqDto.getDataSetsListOne()) {
            infoIndex.put(dataOne.getCustomField1(), dataOne.getComFloatField1());
        }
        BigDecimal sum = new BigDecimal("0");
        for (String one : reqDto.getDataSetsListTwo()) {
            if (infoIndex.containsKey(one)) {
                Double value = infoIndex.get(one);
                sum = sum.add(new BigDecimal(value));
            }
        }
        retData.setDataResult(sum.doubleValue());
        return retData;
    }

    /**
     * code:receptionService
     * name:M2接收出参字段
     * desc:undefined
     * gen by moon at 4/25/2024, 1:49:00 PM
     **/
    @Trace(operationName = "M2接收出参字段")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    public ImplementTenReceivingFieldRespDto implementTenReceivingField(ImplementTenReceivingFieldReqDto reqDto) {
        return BeanUtil.toBean(reqDto, ImplementTenReceivingFieldRespDto.class);
    }
    //手工接入方法
}
